package controller;

import dao.IHisDataDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import util.ExportExcel;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * Created by lvdouStart on 2017/7/11.
 */
@Controller
public class ExcelExportController {

    @Autowired
    private IHisDataDao iHisDataDao;

    @RequestMapping("/index")
    public String page(){
        return "index";
    }


    @RequestMapping("/export")
    public String export(HttpServletRequest request, HttpServletResponse response){
        List<Map> map = iHisDataDao.excelExport();
        try {
            ExportExcel.export(map,"his记录",response,null);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return null;
    }
}
